using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;

namespace WMOSSExperts.PackageBuilder.Addin
{
    public partial class PackageBuilderWizard : Form
    {
        private String _configurationFilePath;

        public PackageBuilderWizard(String configurationFilePath)
        {
            InitializeComponent();

            _configurationFilePath = configurationFilePath;
            this.CheckConfigurationFile();
        }

        private Boolean CheckConfigurationFile()
        {
            if (String.IsNullOrEmpty(_configurationFilePath) || !System.IO.File.Exists(_configurationFilePath))
            {
                ErrorWizardProvider.SetError(TxtConfigurationFilePath, "The configuration file is mandatory to use this wizard");
                TxtConfigurationFilePath.Text = "Select a new configuration file";
                BtnNew.Enabled = true;
            }
            else
            {
                ErrorWizardProvider.SetError(TxtConfigurationFilePath, String.Empty);
                TxtConfigurationFilePath.Text = _configurationFilePath;
                BtnNew.Enabled = false;
            }

            return !BtnNew.Enabled;
        }


        private void BtnNew_Click(object sender, EventArgs e)
        {
            if (SaveNewConfigurationFile.ShowDialog() == DialogResult.OK)
            {
                _configurationFilePath = SaveNewConfigurationFile.FileName;
                this.CheckConfigurationFile();
            }
        }



    }
}